﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Yipusoft.TownshipEnterprise.BLL;

public partial class TownshipEnterprise_AllChart : System.Web.UI.Page
{
    public String SumSy = "";
    public String Sumqsy = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        BindChar();
    }

    private bool BindChar()
    {
        DBCls db = new DBCls();

        //企事业专职消防队
        string sqlqsy = "select * FROM View_TownbasicCharArtQSY ";
        DataView dvqsy = db.QueryDataView(sqlqsy, "qsy");

        DataTable dt = db.QueryDataTable("select * from (select SUM(HE) AS sy FROM View_TownbasicCharArtSY ) as d,(select SUM(HE)AS qsy FROM View_TownbasicCharArtQSY) AS f","sum");

        if (dt.Rows.Count > 0)
        {
            SumSy = dt.Rows[0]["sy"].ToString();
            Sumqsy = dt.Rows[0]["qsy"].ToString();
        }

        //乡镇四有消防队
        string sqlsy = "select * FROM View_TownbasicCharArtSY ";
        DataView dvsy = db.QueryDataView(sqlsy, "sy");

        //UserChart.Series.Add("乡镇四有消防队 总计：" + SumSy);
        UserChart.Titles["Title"].Text = "专职消防队统计图";
        UserChart.ChartAreas["Default"].AxisX.LabelsAutoFit = false;
        UserChart.Series["乡镇四有消防队"].Points.DataBindXY(dvsy, "", dvsy, "he");
        UserChart.Series["企事业消防队"].Points.DataBindXY(dvqsy, "shortname", dvqsy, "he");
        


        for (int i = 0; i < dvqsy.Count; i++)
        {
            UserChart.Series["企事业消防队"].Points[i].Href = "PartChart.aspx?DepartmentID=" + dvqsy[i][0].ToString() + "&Flag=1";
            
        }

        for (int i = 0; i < dvsy.Count; i++)
        {
            UserChart.Series["乡镇四有消防队"].Points[i].Href = "PartChart.aspx?DepartmentID=" + dvsy[i][0].ToString() + "&Flag=2";
        }
        UserChart.Series["乡镇四有消防队"].Name = "乡镇四有消防队 总计：" + SumSy;
        UserChart.Series["企事业消防队"].Name = "企事业消防队 总计：" + Sumqsy;
        return false;
    }

}
